'use strict';

module.exports = app => {
  const { STRING, INTEGER, DATE, Op } = app.Sequelize;

  const Role = app.model.define('english_roles', {
    id: {
      type: INTEGER,
      primaryKey: true,
      autoIncrement: true,
    },
    role_name: STRING(30),
    is_super: INTEGER(1),
  }, {
    freezeTableName: true,
});
  Role.associate = function() {
    app.model.Role.belongsToMany(app.model.User, {
      through: app.model.UserRole,
      foreignKey: 'role_id',
      otherKey: 'user_id', // 单词ID外键
      as: 'users',
    });
  };

  return Role;
};
